/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <vector>

#include <Util/Spatial.h>
#include <Modules/Logic/engine/Engine.h>
#include <Util/octree/octree.h>

namespace galaxy {
    namespace logic {

        namespace gamestate {
            namespace states {
                class GameState;
            }
        }

        namespace engine {

            /** name for use in Engine::engineName() */
            static Engine::Name c_GalaxyEngineName = "GalaxyEngine";

            namespace galaxy {

                class Sector;

                /** This class controls the aspects of the 'galactic' environment */
                class GalaxyEngine : public Engine
                {
                    static Octree<Sector *> m_GalaxyMap;

                public:
                    GalaxyEngine(gamestate::StatePtr& gameState);
                    virtual ~GalaxyEngine(void);

                    virtual bool initialize ();
                    virtual bool terminate ();
                    virtual bool activate ();
                    virtual bool deactivate ();

                    bool initializeEntityProperties();
                    bool initializeGalaxy ();
                    bool getVisibleEntities (std::vector<entity::Entity *>& stars);

                    virtual Engine::Name engineName () { return engine::c_GalaxyEngineName; };

                private:
                    Sector * setupSector (util::Vector<float>& min);
                    gamestate::states::GameState * getGameState ();            
                };

            } // namespace galaxy
        } // namespace engine
    } // namespace logic
} // namespace galaxy
